<?php
/*
Template Name: Homepage
*/
?>
<?php get_header(); ?>
</div><!-- header-area -->
</div><!-- end rays -->
</div><!-- end header-holder -->
</div><!-- end header -->

<?php truethemes_before_main_hook();// action hook, see truethemes_framework/global/hooks.php ?>

<div id="main">
    <div class="main-area home-main-area">
        <div class="main-holder home-holder">
            <div class="content_full_width">

                <div class="home-bnr-jquery">
                    
                    <div class="slide-list">
                        <ul id="home-slide">
                            <?php

                            //remove filter added by wploop_exclude() from truethemes_framework/global/theme_functions.php
                            remove_filter('pre_get_posts','wploop_exclude');

                            //Get jQuery slider post category set by user in admin Site Options.
                            $jcycle_category = get_option('ka_jcycle_category'); 
                            $jcycle_category_id = get_cat_id($jcycle_category); 

                            //start WordPress Loop to retrieve post from selected category,
                            //if no category is set, all posts will be returned.

                            $query_string ="posts_per_page=100&cat=$jcycle_category_id";
                            query_posts($query_string);

                            if (have_posts()) : while (have_posts()) : the_post();

                            //process all individual post meta.

                            //post meta - Link This Image 
                            $jcycle_url = get_post_meta($post->ID, '_jcycle_url_value', true);

                            //post meta - Feature Image (External Source)
                            $external_image_url = get_post_meta($post->ID,'truethemes_external_image_url',true);

                            //post meta - Featured Video
                            //$jquery_video_url = get_post_meta($post->ID,'truethemes_video_url',true);

                            //post meta - Feature Image
                            $thumb = get_post_thumbnail_id();

                            //half width image details
                            $image_width = 940;
                            $image_height = 322;

                            //assign half image src, uses function from truethemes_framework/global/basic.php
                            $image = truethemes_crop_image($thumb,$external_image_url,$image_width,$image_height);

                            ?>

                            <li class="jqslider">

                                <?php 
                                //If image is not empty, we show half image, half content.
                                if(!empty($image)) : 
                                ?>

                                    <div class="home-banner-image">
                                        <?php if ($jcycle_url == ''){ ?>
                                            <img src="<?php echo $image; ?>" width="<?php echo $image_width; ?>" height="<?php echo $image_height; ?>" alt="<?php the_title(); ?>" />
                                        <?php }else{
                                            echo '<a href="'.$jcycle_url.'">'; ?>
                                            <img src="<?php echo $image; ?>" width="<?php echo $image_width; ?>" height="<?php echo $image_height; ?>" alt="<?php the_title(); ?>" />
                                        <?php echo '</a>'; }?>
                                    </div><!-- end home-banner-sub --> 

                            </li>
                            <?php endif;endwhile; endif;wp_reset_query(); ?>
                        </ul>
                    </div>
                </div><!-- end home-bnr-jquery -->

                <div class="sidebar-widgets">
                    <?php dynamic_sidebar("Home Dinos Algo"); ?>
                    <?php dynamic_sidebar("Home Botones"); ?>
                    <?php dynamic_sidebar("Home Posts"); ?>
                </div>

                
            </div><!-- end content -->
        </div><!-- end main-holder -->
    </div><!-- main-area -->

<?php get_footer(); ?>